<div class="layui-form form-wrap">
    <div class="layui-card card-common card-brief">
        <div class="layui-card-header">
            <span class="card-title">基础设置</span>
        </div>
        <div class="layui-card-body">
            
            <div class="layui-form-item">
                <label class="layui-form-label">是否开启链动2+1：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="is_open" value="1" lay-filter="open_lian" title="开启" {if $basics_info.is_open == 1} checked {/if}/>
                        <input type="radio" name="is_open" value="0" lay-filter="open_lian" title="关闭" {if $basics_info.is_open == 0} checked {/if}/>
                    </div>
                </div>
            </div>
            
            <!-- <div class="layui-form-item lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
                <label class="layui-form-label">是否开启注册升级：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="up_register" value="1" title="开启" {if $basics_info.up_register == 1} checked {/if}/>
                        <input type="radio" name="up_register" value="0" title="关闭" {if $basics_info.up_register == 0} checked {/if}/>
                    </div>
                </div>
            </div> -->

            <div class="layui-form-item lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
                <label class="layui-form-label">升级触发方式：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="up_way" value="0" title="支付后" {if $basics_info.up_way == 0} checked {/if}/>
                        <input type="radio" name="up_way" value="1" title="完成后" {if $basics_info.up_way == 1} checked {/if}/>
                    </div>
                </div>
                <div class="word-aux">开启后支付完成即可触发升级，关闭后需要订单完成才能触发升级</div>
            </div>

            <div class="layui-form-item lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
                <label class="layui-form-label">提成类型：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="take_type" value="0" title="余额" {if $basics_info.take_type == 0} checked {/if}/>
                        <input type="radio" name="take_type" value="1" title="佣金" {if $basics_info.take_type == 1} checked {/if}/>
                        <input type="radio" name="take_type" value="2" title="积分" {if $basics_info.take_type == 2} checked {/if}/>
                        <!-- <input type="radio" name="take_type" value="3" title="数字积分" {if $basics_info.take_type == 3} checked {/if}/> -->
                    </div>
                </div>
            </div>

            <!-- <div class="layui-form-item lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
                <label class="layui-form-label">是否匹配多门店订单：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="is_store" value="1" title="是" {if $basics_info.is_store == 1} checked {/if}/>
                        <input type="radio" name="is_store" value="0" title="否" {if $basics_info.is_store == 0} checked {/if}/>
                    </div>
                </div>
            </div> -->
        </div>
    </div>

    <div class="layui-card card-common card-brief lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
        <div class="layui-card-header">
            <span class="card-title">结算设置</span>
        </div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">结算方式：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="settle_way" value="0" title="订单支付后" {if $basics_info.settle_way == 0} checked {/if}/>
                        <input type="radio" name="settle_way" value="1" title="订单完成后" {if $basics_info.settle_way == 1} checked {/if}/>
                    </div>
                </div>
                <div class="word-aux">选择不同的结算方式，会影响佣金的结算时间</div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">结算周期：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="number" min="0" name="settle_cycle" value="{$basics_info.settle_cycle}" lay-verify="required" autocomplete="off" class="layui-input len-short" title="结算周期" placeholder="请输入结算周期">
                    </div>
                    <div class="layui-form-mid">天</div>
                </div>
                <div class="word-aux">订单符合结算条件后，需要经过结算周期才能进行提现</div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">计算方式：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="count_type" value="0" title="支付金额" {if $basics_info.count_type == 0} checked {/if}/>
                        <input type="radio" name="count_type" value="1" title="商品现价" {if $basics_info.count_type == 1} checked {/if}/>
                        <!-- <input type="radio" name="count_type" value="2" title="商品原价" {if $basics_info.count_type == 2} checked {/if}/> -->
                    </div>
                </div>
                <div class="word-aux">支付金额：以用户最终支付的金额（含优惠）作为佣金计算基数</div>
                <div class="word-aux">商品现价：以商品销售价格作为佣金计算基数</div>
                <div class="word-aux">商品原价：以商品原价作为佣金计算基数</div>
            </div>
        </div>
    </div>

    <div class="layui-card card-common card-brief lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
        <div class="layui-card-header">
            <span class="card-title">奖励设置</span>
        </div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">直推奖励冻结：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="first_reward_frozen" value="1" title="开启" {if $basics_info.first_reward_frozen == 1} checked {/if}/>
                        <input type="radio" name="first_reward_frozen" value="0" title="关闭" {if $basics_info.first_reward_frozen == 0} checked {/if}/>
                    </div>
                </div>
                <div class="word-aux">开启后，直推奖励将被冻结，需要完成指定任务后才能解冻</div>
            </div>
        </div>
        
        <!-- 是否开启复购见单奖 -->
        <div class="layui-form-item">
            <label class="layui-form-label">是否开启复购见单奖：</label>
            <div class="layui-input-block">
                <div class="layui-input-inline">
                    <input type="radio" name="is_fusee" value="1" title="开启" {if $basics_info.is_fusee == 1} checked {/if}/>
                    <input type="radio" name="is_fusee" value="0" title="关闭" {if $basics_info.is_fusee == 0} checked {/if}/>
                </div>
            </div>
            <div class="word-aux">开启后，将产生复购见单奖</div>
        </div>

         <!-- 复购见点层级 -->
         <div class="layui-form-item">
            <label class="layui-form-label">复购见点层级限制：</label>
            <div class="layui-input-block">
                <div class="layui-input-inline">
                    <input type="number" name="fusee_level" value="{$basics_info.fusee_level}" lay-verify="required" autocomplete="off" class="layui-input len-short" title="复购见点层级" placeholder="请输入复购见点层级">
                </div>
            </div>
        </div>
        
        <!-- <div class="layui-form-item">
            <label class="layui-form-label">复购见单规则：</label>
            <div class="layui-input-block">
                <div class="layui-form-mid">下几单</div>
                <div class="layui-input-inline">
                    <input type="number" name="order_num" value="{$basics_info.order_num}" lay-verify="required" autocomplete="off" class="layui-input len-short" title="复购见单规则" placeholder="请输入复购见单规则">
                </div>
                <div class="layui-form-mid">解锁几层</div>                
                <div class="layui-input-inline">
                    <input type="number" name="level_num" value="{$basics_info.level_num}" lay-verify="required" autocomplete="off" class="layui-input len-short" title="复购见单规则" placeholder="请输入复购见单规则">
                </div>
                <div class="layui-form-mid">复购的第几单</div>
                <div class="layui-input-inline">
                    <input type="number" name="fugou_num" value="{$basics_info.fugou_num}" lay-verify="required" autocomplete="off" class="layui-input len-short" title="复购见单规则" placeholder="请输入复购见单规则">
                </div>
            </div>
        </div> -->
        
    </div>

    <div class="layui-card card-common card-brief lian-index {if $basics_info.is_open == 0}layui-hide{/if}">
        <div class="layui-card-header">
            <span class="card-title">排位设置</span>
        </div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <label class="layui-form-label">是否开启排位：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="is_publine" value="1" title="开启" {if $basics_info.is_publine == 1} checked {/if}/>
                        <input type="radio" name="is_publine" value="0" title="关闭" {if $basics_info.is_publine == 0} checked {/if}/>
                    </div>
                </div>
                <div class="word-aux">开启后，新链动会员将进行排位</div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">公排模式：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="publine_mode" value="1" title="二二公排" {if $basics_info.publine_mode == 1} checked {/if}/>
                        <input type="radio" name="publine_mode" value="2" title="三三公排" {if $basics_info.publine_mode == 2} checked {/if}/>
                        <!-- <input type="radio" name="publine_mode" value="3" title="五五公排" {if $basics_info.publine_mode == 3} checked {/if}/> -->
                    </div>
                </div>
                <div class="word-aux">选择不同的公排模式，每个节点下的人数会不同</div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">公排类型：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="publine_type" value="1" title="小公排直推优先" {if $basics_info.publine_type == 1} checked {/if}/>
                        <input type="radio" name="publine_type" value="2" title="大公排" {if $basics_info.publine_type == 2} checked {/if}/>
                    </div>
                </div>
                <div class="word-aux">小公排直推优先：直推的人会优先排在自己的团队下</div>
                <div class="word-aux">大公排：按照时间顺序排队</div>
            </div>
            
            <!-- <div class="layui-form-item">
                <label class="layui-form-label">入排模式：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline">
                        <input type="radio" name="inline_way" value="1" title="注册入排" {if $basics_info.inline_way == 1} checked {/if}/>
                        <input type="radio" name="inline_way" value="2" title="拍单入排" {if $basics_info.inline_way == 2} checked {/if}/>
                    </div>
                </div>
                <div class="word-aux">注册入排：会员注册成为会员后即可进入排位</div>
                <div class="word-aux">拍单入排：会员需购买指定商品成为代理后才能进入排位</div>
            </div> -->
        </div>
    </div>

    <div class="form-row" style="margin-top:0;padding-left:20px;">
        <button class="layui-btn" lay-submit lay-filter="save">保存</button>
    </div>
</div>

<script>
	layui.use(['form'], function() {
		var form = layui.form,
			openLian = "{$basics_info.is_open}",
			repeat_flag = false; //防重复标识
		    form.render();

        form.verify({
            required: function (value, elem) {
                if (!/[\S]+/.test(value)) {
                    return '必填项不能为空';
                }
            }
        });

        form.on('submit(save)', function(data) {
			if (repeat_flag) return;
			repeat_flag = true;

			$.ajax({
				type: 'POST',
				dataType: 'JSON',
				url: ns.url("lian://shop/config/basics"),
				data: data.field,
				success: function(res) {
					layer.msg(res.message);
					repeat_flag = false;
                    if (res.code == 0) {
                        location.reload();
                    }
				}
			});
            return false;
		});
		
		form.on('radio(open_lian)', function(data){
			openLian = data.value;
			if (!parseInt(openLian)){
				$(".lian-index").addClass('layui-hide');
				return false;
			}
			$(".lian-index").removeClass('layui-hide');
		});
	});
</script>

